﻿@using System.Data;
@using Shop.Entity;
@using Shop.Help;
@using Shop.Bll;
@using Webdiyer.WebControls.Mvc
@using System.Web.Mvc.Ajax;
@model  PagedList<DataRow>
@{
    string actionString = RoleLogic.GetPowerStr("Article", ManagerLogic.GetLoginInfo().ManagerRoleGuid);
    Layout = null;
}

<table class="table table-bordered  table-condensed table-condensed  table-hover table-condensed">
    <thead>
        <tr>
            <th></th>
            <th>标题</th>
            <th>缩略图</th>
            <th>所属分类</th>
            <th>来源</th>
            <th>新页面打开</th>
            <th>显示顺序</th>
            <th>点击量</th>
            <th>状态</th>
            <th>添加时间</th>
            <th class="hidden-xs">操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var row in Model)
        {
            <tr>
                <td>
                    <input type="checkbox" name="subBox" value="@row["Guid"]" id="ck@(row["Guid"])" />
                </td>
                @if (row["Title"].ToString().Length >= 20)
                {
                    <td class="title" id="@row["Guid"]" onmouseover="ShowMsg('@row["Guid"]','@row["Title"]')">@row["Title"].ToString().Substring(0, 20)  ...</td>
                }
                else
                {
                    <td class="title">@row["Title"]</td>
                }
                <td style="padding: 5px;">
                    <img onmouseover="MouseShowImage(this);" style="height:25px;width:40px;" alt="" src="@row["SmallImg"]" onerror="this.src='/Content/noImg.jpg'" />
                </td>
                <td>@row["ClassTitle"]</td>
                <td>@row["Souce"]</td>
                <td>@(row["Target"].ToString() == "_self" ? "否" : "是")</td>
                <td>@row["Sort"]</td>
                <td>@row["Click"]</td>
                <td>@row["Status"]</td>
                <td>@Convert.ToDateTime(row["AddTime"]).ToString("yyyy-MM-dd HH:mm")</td>
                <td>
                    @if (actionString.Contains("Edit"))
                    {
                        <a class="btn btn-default btn-xs" title='编辑信息' href="/articleinfo/article/add/@row["Guid"]?pageIndex=@Model.CurrentPageIndex">编辑</a>
                    }
                    @if (actionString.Contains("Delete"))
                    {
                        <a class="btn btn-default btn-xs" title='' onclick="Delete('@row["Guid"]','/articleinfo/article/delete','/articleinfo/article/list/@(Model.CurrentPageIndex - 1 > 1 ? Model.CurrentPageIndex - 1 : 1)');">删除 </a>

                    }
                </td>
            </tr>
        }
    </tbody>
</table>
<input type="hidden" value="@Model.CurrentPageIndex" id="PageIndex" />

<input type="hidden" value="@Model.TotalPageCount" id="TotalPageCount" />
<div class="col-xs-9" style="width:auto;padding-left:0px;">
    <ul class="pagination">
        <li>
            <span aria-hidden="true">
                @(Model.PageSize)条/页，@(Model.TotalPageCount)页, 共@(Model.TotalItemCount)条
            </span>
        </li>
        <li>
            <span aria-hidden="true">
                每页
                <select style="border-radius:4px;font-family:normal;vertical-align: text-bottom;" id="PageSize" name="PageSize" onchange="PageSizeChange();">
                    <option value="10">10</option>
                    <option selected="selected" value="15">15</option>
                    <option value="20">20</option>
                </select>
                条
            </span>
        </li>
    </ul>
    @Ajax.Pager(Model,
        new PagerOptions
        {
            PageIndexParameterName = "id",
            CssClass = "pagination",
            FirstPageText = "首页",
            LastPageText = "尾页",
            PrevPageText = "上一页",
            PageIndexBoxId = "pageIndexBox",
            GoToButtonId = "Go",
            PageIndexOutOfRangeErrorMessage = "页码有误!",
            NumericPagerItemCount = 8,
            NextPageText = "下一页",
            CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
            DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
            PagerItemTemplate = "<li>{0}</li>",
            AutoHide = false,

        }, new MvcAjaxOptions
        {
            UpdateTargetId = "divTable",
            HttpMethod = "Post",
            DataFormId = "formSearch",
            EnableHistorySupport = false,
            OnSuccess = "Success();"
            //EnablePartialLoading = true
        }
        )
</div>
<div class="pagination" style="width:20%;margin-top: 0px;">
    <ul class="pagination">
        <li>
            <div class="input-group">
                <span class="input-group-addon">第</span>
                <input type="text" id="pageIndexBox" class="form-control input-sm" placeholder="" aria-describedby="sizing-addon2" oninput="InputPageIndex(this);">
                <span class="input-group-addon">页</span>
                <span class="input-group-btn">
                    <button class="btn btn-primary btn-sm" id="Go" type="button">Go</button>
                </span>
            </div>
        </li>
    </ul>
</div>

